package swg;

import java.util.ArrayList;

import swg.shape.IswgShape;
import swg.utils.WriteFile;

public class MakeSVGFile
{
	
	protected String path="";
	protected ArrayList<IswgShape> shapes = new ArrayList<IswgShape>();
	protected String begin="<?xml version=\"1.0\" standalone=\"no\"?><!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\" \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n<svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\">\n";
	protected String end="\n</svg>";

	public MakeSVGFile(String path, ArrayList<IswgShape> shapes)
	{
		this.path=path;
		this.shapes=shapes;
	}

	public void process()
	{
		StringBuffer code= new StringBuffer(begin);
		System.out.println("Start Writing...");
		int sn=0;
		for(IswgShape s: shapes){
			code.append("\t");
			code.append(s.getSWGCode());
			sn++;
			System.out.println("written"+(shapes.size()-sn));
		}
		code.append(end);
		WriteFile wf = new WriteFile(path, code.toString());
		wf.write();
		System.out.println("saved file: "+path);
	}



}
